1.1.1. 2.1.3 鼠标悬停显示遮罩层-提高
sass 文件
.box99 {
/*外层相对位置*/
position: relative;
.course-img {
/*定位*/
position: absolute;
z-index: 1;
img {
/*定形*/
width: 220px;
height: 160px;
}
}
.title {
/*定位*/
position: absolute;
z-index: 3;
/*定形*/
width: 220px;
h3 {
margin-top: 125px;
font-size: 15px;
color: #333;
line-height: 40px;
padding-left: 10px;
letter-spacing: 1px;
}
}
.title-cover {
/*定位*/
position: absolute;
z-index: 2;
margin-top: 125px;
/*定形*/
width: 220px;
height: 35px;
/*样式*/
background-color: rgba(225, 225, 225, 0.8);
}
.block {
/*定位*/
position: absolute;
z-index: 2;
margin-top: 160px;
/*定形*/
height: 70px;
width: 220px;
/*样式*/
padding: 6px 10px;
border-top: 1px solid #DEDEDE; /*分割线*/
background-color: #f9f9fa;
.time {
font-size: 13px;
}
.bar {
/*样式*/
overflow: hidden;
background-color: #ccc;
height: 4px;
width: auto;
margin: 13px 0 5px;
border-radius: 4px;
.percent {
width: 40%;
height: 4px;
background-color: #1ECD97;
}
}
.task {
font-size: 13px;
}
}
a {
.start {
/*定位*/
position: absolute;
z-index: 5;
top: 0;
/*定形*/
width: 220px;
height: 230px;
/*样式*/
opacity: 0; /*隐藏*/
background: rgba(101, 101, 101, 0.6);
color: #fff;
text-align: center;
padding-top: 80px;
}
&:hover {
.start {
opacity: 1;/*显示*/
}
}
}
}
html 文件
<div class="box99">
<div class="course-img">
<%= image_tag("https://ws3.sinaimg.cn/large/006tNbRwgy1fvziqfqj28j30et08c74m.jpg") %>
</div>
<div class="title">
<h3>百宝箱</h3>
</div>
<div class="title-cover"></div>
<div class="block">
<p class="time">预计学习时间: 7小时</p>
<div class="bar">
<div class="percent"></div>
</div>
<p class="task">共1个作业,已完成0个</p>
</div>
<a href="#">
<div class="start">
<button type="button" class="btn btn-success">进入课程</button>
</div>
</a>
</div>